/*
 * @Description:
 * @Author: Rfan
 * @Date: 2022-01-20 10:10:33
 * @LastEditTime: 2023-01-15 15:06:28
 */

import SearchResultHeader from '../../components/ResultPage/SearchResultHeader';

import { useLocation } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { useSearchResultContext } from '../../components/ResultPage/contexts/SearchResultContext';
import TabHeadMain from '../../components/ResultPage/TabHeadMain';

const AdvanceResultWarp = () => {
  const { additionalSearch } = useSearchResultContext();
  const location = useLocation();
  const { state: routeState }: any = location;
  const data = routeState.data || [];
  const [results, setResults] = useState(data);
  console.log('results', results);
  useEffect(() => {
    if (Object.keys(additionalSearch).length === 0) return;
    setResults(additionalSearch);
  }, [additionalSearch]);

  return (
    <div>
      <SearchResultHeader />
      <TabHeadMain results={results} type={routeState.type} />
    </div>
  );
};

export default AdvanceResultWarp;
